/*
 * Copyright 2006 Berry Crawford
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.judo.database;

import org.judo.database.exceptions.DatabaseConnectionException;
import org.judo.database.exceptions.DatabaseException;
import org.judo.database.exceptions.ORMException;
import org.judo.propertyobject.PropertyObject;

public interface Database
{	
	public void insert(PropertyObject obj) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void insert(String entityName, PropertyObject obj) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void insert(PropertyObject obj,String insertStatement) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void delete(String entityName,PropertyObject obj) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void delete(PropertyObject obj) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void delete(PropertyObject obj,String deleteStatement) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void delete(PropertyObject obj,int id) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void delete(String entityName,int id) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void update(PropertyObject obj) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void update(PropertyObject obj,String sql) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void update(String entityName,PropertyObject obj) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public int exec(String sql) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public JudoResultSet query(String sqlStatement) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public JudoResultSet query(Class resultType,String whereClause) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public JudoResultSet queryEntity(String entityName) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public JudoResultSet queryEntity(String entityName,String... orderByColumns) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public JudoResultSet queryEntity(String entityName,String whereClause) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public JudoResultSet queryAll(Class resultType) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public JudoResultSet queryAll(Class resultType,String... orderByColumns) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public PropertyObject find(String sqlStatement) 
		throws DatabaseConnectionException,ORMException,DatabaseException;

	public PropertyObject find(Class resultType,String whereClause) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public PropertyObject find(Class resultType,int id) 
		throws DatabaseConnectionException,ORMException,DatabaseException;
	
	public void populateTransactionalConnection(JudoDBConnection con);
	
	public void manuallyCommit() 
		throws DatabaseException;
	
	public void manuallyRollback() 
		throws DatabaseException;
	
	public ConnectionFactory getConnectionFactory();
	public void defineConnectionFactory(ConnectionFactory factory);
}
